package com.heima.tess4j;

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;

/**
 * @Author: xsz
 * @DateTime: 2024/2/15 23:58
 **/


public class Tess4jApplication {

    /**
     * 识别图片中的文字
     * @param args
     */
    public static void main(String[] args) throws TesseractException {

        //创建实例
        ITesseract tesseract = new Tesseract();

        //设置字体库路径
        tesseract.setDatapath("C:\\Users\\1972454587\\Desktop\\code\\HeiMaTouTiao\\develop\\Tess4jData");

        //设置语言
        tesseract.setLanguage("chi_sim");

        File file = new File("C:\\Users\\1972454587\\Desktop\\code\\HeiMaTouTiao\\develop\\违规图片测试\\图片1.png");

        String s = tesseract.doOCR(file);

        System.out.println(s);

    }

}
